<template src="../view/libraryPush.vue"></template>

<script>
import { tagAsk } from '../event/ask.js'
import request from '../link/request.js'
export default {
  name: 'LibraryPush',
  data () {
    return {
      title: '',
      price: '',
      leavel: '',
      url: '',
      desc: ''
    }
  },
  mounted () {
    tagAsk()
    this.markdown()
  },
  methods: {
    markdown () {
      editormd ("markdown", {
        width   : "99.5%",
        height  : 380,
        syncScrolling : "single",
        path    : "/static/editor.md/lib/"
      })
    },
    push (res) {
      let that = this
      console.log(res)
      request.post('/index.php/main/download/push', {
        title: this.title,
        price: that.price,
        leavel: that.leavel,
        url: that.url,
        desc: $('#desc').val()
      })
        .then(function (response) {
          console.log(response)
          if (response.code === 1) {
            layer.msg(response.msg, {icon: response.code})
            setTimeout(that.redirect('download'), 5000)
          } else {
            layer.msg(response.msg, {icon: response.code})
          }
        })
    }
  }
}
</script>

<style src="../assets/css/libpush.css" scoped></style>
<style src="../assets/css/form.css" scoped></style>
